<?php
require_once 'database/GrosseryList.php';
require_once 'database/DatabaseConnection.php';

/**
 * Tests the functions of grocerylist
 * @author Denis
 * @version 1.1
 */
class GrosseryListTest {
	
	private $userId = 1;
	private $name = "TestBoodschappenlijst";
	private $userIdNE;
	private $grosseryList;
	
	public function __construct(){
		$this->grosseryList = new GrosseryList();
		DatabaseConnection::connect();
		$this->userIdNE = $this->grosseryList->getHighestGrosseryListId();
		DatabaseConnection::disconnect();
	}
	
	/**
	 * Tests the select groceryList function
	 * @Return true or false
	 */
	public function TestReadGrosseryList(){
		$bool = false;
		DatabaseConnection::connect();
		$arrObj = $this->grosseryList->readGrosseryList($this->userId);
		if(is_object($arrObj)){
			$bool = true;
		}
		DatabaseConnection::disconnect();
		return $bool;
	}
	
	/**
	 * Test the Insert grocery list function and wheter its check on one list per user works
	 * @Return true or false
	 */
	public function testCreateGrosseryList(){
		$bool = true;
		DatabaseConnection::connect();
		$boolean = $this->grosseryList->createGrosseryList($this->userIdNE, $this->name);
		if($boolean == true){
			$bool = false;
		}
		$boolean = $this->grosseryList->createGrosseryList(($this->userIdNE + 1), $this->name);
		if($boolean == false){
			$bool = false;
		}
		DatabaseConnection::disconnect();
		return $bool;
	}
}